package cn.iocoder.yudao.module.eval.dal.mysql.score;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.eval.controller.admin.score.vo.EvalScoreSummaryPageReqVO;
import cn.iocoder.yudao.module.eval.dal.dataobject.score.EvalScoreSummaryDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.Collection;
import java.util.List;

/**
 * 成绩汇总 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface EvalScoreSummaryMapper extends BaseMapperX<EvalScoreSummaryDO> {

    default PageResult<EvalScoreSummaryDO> selectPage(EvalScoreSummaryPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<EvalScoreSummaryDO>()
                .eqIfPresent(EvalScoreSummaryDO::getPlanId, reqVO.getPlanId())
                .eqIfPresent(EvalScoreSummaryDO::getCandidateId, reqVO.getCandidateId())
                .eqIfPresent(EvalScoreSummaryDO::getAppliedLevel, reqVO.getAppliedLevel())
                .eqIfPresent(EvalScoreSummaryDO::getEvaluationResult, reqVO.getEvaluationResult())
                .eqIfPresent(EvalScoreSummaryDO::getGradeLevel, reqVO.getGradeLevel())
                .eqIfPresent(EvalScoreSummaryDO::getIsFinal, reqVO.getIsFinal())
                .eqIfPresent(EvalScoreSummaryDO::getReviewStatus, reqVO.getReviewStatus())
                .betweenIfPresent(EvalScoreSummaryDO::getCalculationTime, reqVO.getCalculationTime())
                .betweenIfPresent(EvalScoreSummaryDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(EvalScoreSummaryDO::getId));
    }

    default List<EvalScoreSummaryDO> selectListByPlanId(Long planId) {
        return selectList(EvalScoreSummaryDO::getPlanId, planId);
    }

    default List<EvalScoreSummaryDO> selectListByPlanIds(Collection<Long> planIds) {
        return selectList(new LambdaQueryWrapperX<EvalScoreSummaryDO>()
                .in(EvalScoreSummaryDO::getPlanId, planIds));
    }

    default EvalScoreSummaryDO selectByPlanIdAndCandidateId(Long planId, Long candidateId) {
        return selectOne(new LambdaQueryWrapperX<EvalScoreSummaryDO>()
                .eq(EvalScoreSummaryDO::getPlanId, planId)
                .eq(EvalScoreSummaryDO::getCandidateId, candidateId));
    }

    default List<EvalScoreSummaryDO> selectListByEvaluationResult(Integer evaluationResult) {
        return selectList(EvalScoreSummaryDO::getEvaluationResult, evaluationResult);
    }

    default List<EvalScoreSummaryDO> selectListByGradeLevel(String gradeLevel) {
        return selectList(EvalScoreSummaryDO::getGradeLevel, gradeLevel);
    }

    default List<EvalScoreSummaryDO> selectListByIsFinal(Boolean isFinal) {
        return selectList(EvalScoreSummaryDO::getIsFinal, isFinal);
    }

    default List<EvalScoreSummaryDO> selectListByReviewStatus(Integer reviewStatus) {
        return selectList(EvalScoreSummaryDO::getReviewStatus, reviewStatus);
    }

    default List<EvalScoreSummaryDO> selectList(EvalScoreSummaryPageReqVO exportReqVO) {
        return selectList(new LambdaQueryWrapperX<EvalScoreSummaryDO>()
                .eqIfPresent(EvalScoreSummaryDO::getPlanId, exportReqVO.getPlanId())
                .eqIfPresent(EvalScoreSummaryDO::getCandidateId, exportReqVO.getCandidateId())
                .eqIfPresent(EvalScoreSummaryDO::getAppliedLevel, exportReqVO.getAppliedLevel())
                .eqIfPresent(EvalScoreSummaryDO::getEvaluationResult, exportReqVO.getEvaluationResult())
                .eqIfPresent(EvalScoreSummaryDO::getGradeLevel, exportReqVO.getGradeLevel())
                .eqIfPresent(EvalScoreSummaryDO::getIsFinal, exportReqVO.getIsFinal())
                .eqIfPresent(EvalScoreSummaryDO::getReviewStatus, exportReqVO.getReviewStatus())
                .betweenIfPresent(EvalScoreSummaryDO::getCalculationTime, exportReqVO.getCalculationTime())
                .betweenIfPresent(EvalScoreSummaryDO::getCreateTime, exportReqVO.getCreateTime())
                .orderByDesc(EvalScoreSummaryDO::getId));
    }

}
